<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>灯泡开关</title>
		<style type="text/css">
			div#box{
				text-align: center;
			}
			div#box div#btn{
				margin: 5px auto;
				width: 50px;
				height: 50px;
				line-height: 50px;
				background-color: #808080;
				border-radius: 50%;
				color: white;
				cursor: pointer;
			}
		</style>
	</head>
	<body>
		<div id="box">
			<div id="btn">开</div>
			<img id="img" src="img/pic_bulboff.gif" alt="" />
		</div>
		<script type="text/javascript">
			(function(){
				var btn=document.querySelector("#btn");
				var img=document.querySelector("#img");
				btn.onclick=function(){
					console.log("this:",this);
					if(this.innerHTML=="开"){
					   img.src="img/pic_bulbon.gif";
					   this.innerHTML="关";
					   this.style.backgroundColor="red";
					}else{
						img.src="img/pic_bulboff.gif";
						this.innerHTML = "开";
						this.style.backgroundColor = "blue";
					}
				}
			}());
		</script>
	</body>
</html>
